<template>
  <div id="centreRight1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span style="color:#5cd9e8">
          <icon name="chart-line"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-x text mx-2">商家销售排行榜</span>
        </div>
      </div>
      <div class="d-flex jc-center ">
        <dv-scroll-board :config="config" style="width:7.375rem;height:4.28rem" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      config: {
        header: ["商家ID","商家名称" ,"销售额(元)"],
        data: [],
        rowNum: 7, //表格行数
        headerHeight: 35,
        headerBGC: "#0f1325", //表头
        oddRowBGC: "#0f1325", //奇数行
        evenRowBGC: "#171c33", //偶数行
        index: true,
        columnWidth: [100,200,440,200],
        align: ["center","center","center","center"]
      }
    };
  },
  components: {},
  mounted() {
    this.getTopsellers()
    this.timer()
  },
  methods:{
    async getTopsellers(){
      const res = await this.$http.get('/top/sellers/10')
      this.config = { ...this.config,data: res }
    },
    timer() {
      return setInterval(()=>{
        this.getTopsellers()
      },60000)
    }
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer); // 在Vue实例销毁前，清除我们的定时器
    }
  }
};
</script>

<style lang="scss">
#centreRight1 {
  padding: 0.2rem;
  height: 5.125rem;
  min-width: 3.75rem;
  border-radius: 0.0625rem;
  .bg-color-black {
    height: 4.8125rem;
    border-radius: 0.125rem;
  }
  .text {
    color: #c3cbde;
  }
  .body-box {
    border-radius: 0.125rem;
    overflow: hidden;
  }
}
</style>
